home *** CD-ROM | disk | FTP | other *** search
- Path: news.cs.columbia.edu!news-not-for-mail
- From: jean@news.cs.columbia.edu (Hyae-Jin Oh)
- Newsgroups: comp.lang.c++
- Subject: [HELP] ostream inheritance Q?
- Date: 28 Mar 1996 17:42:52 -0500
- Organization: Columbia University Department of Computer Science
- Message-ID: <4jf4lc$t8l@ground.cs.columbia.edu>
- NNTP-Posting-Host: ground.cs.columbia.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
-
- i'm trying to come up with new output stream, say Nostream,
- which provides some more functionality beyond ostream as follows.
-
- --------------------------------------------------
- class Nostream : public ostream {
- public:
- Nostream(streambuf *sb) : ios(sb) {}
- ~Nostream() {}
-
- Nostream& foo(const char *msg) {
- return *this << mime;
- }
-
- Nostream& operator << ( Nostream& (*funcPtr)(const char *msg)
- ) {
- return (*funcPtr)(msg);
- }
-
- .... // some more functionality...
- }
-
- int main()
- {
- Nostream nout(cout.rdbuf());
-
- nout << "TEST" << endl;
-
- nout.header("blah"); --------- 1
- nout << header("blah"); --------- 2
- }
- --------------------------------------------------
-
- my intention of providing overloaded "<<" operator
- which gets function pointer as a parameter is
- to use statements "1" and "2" interchangably like above
- with same effect.
-
- however, this doesn't pass through Sun Sparc 3.1 CC compiler:
- it generates lots of warning and one error. what am i doing wrong
- here? other than this error, all others are working correctly.
- many thanks.
-
- (line number is bogus)
- --------------------------------------------------
- /opt/SUNWspro/bin/CC -c -g +w2 -D__SOLARIS__ -DDEBUG_ASSERT foo.C
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(char).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(ios&(*)(ios&)).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(ostream&(*)(ostream&)).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(streambuf*).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(const void*).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(void*).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(const char*).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(long double).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(double).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(float).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(unsigned long long).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(long long).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(unsigned long).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(long).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(unsigned).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(int).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream
- ::operator<<(unsigned short).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(short).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(const wchar_t*).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(wchar_t).
- "foo.H", line 61: Warning: Nostream::operator<< hides the function
- ostream::operator<<(unsigned char).
- "foo.C", line 38: Error: msg is not defined. <<<--------!!!!
- 1 Error(s) and 23 Warning(s) detected.
- --
- Hyae-Jin Oh
- jean@cs.columbia.edu
- http://www.cs.columbia.edu/~jean/
-